package com.lab.service.impl;

import com.lab.dao.OexDao;
import com.lab.pojo.Oexperiment;
import com.lab.service.OexService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("oexService")
public class OexServiceImp implements OexService {
    @Resource
    OexDao oexDao;
    //查询所有数据
    public List<Oexperiment> allOexperiments() {
        return oexDao.allOexperiments();
    }
    //添加和修改
    public void saveOexperiment(Oexperiment oexperiment) {
        try {
            Oexperiment o= oexDao.findOexById(oexperiment.getOeId());
            if (o!=null){
                //修改
                oexDao.updateOexperiment(oexperiment);
            }else {
                //增加
                oexDao.addOexperiment(oexperiment);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //删除
    public void deleteOexperiment(Long[] oeId) {
        oexDao.deleteOexperiment(oeId);
    }

    public Oexperiment findOexById(Long oeId) {
        return oexDao.findOexById(oeId);
    }

    //预约开放实验
    public void ordOexperiment(Oexperiment oexperiment) {
        oexDao.addOexperiment(oexperiment);
    }

    public void passOexByLabmanager(Long[] oeId) {
        oexDao.passOexByLabmanager(oeId);
    }

    public void unpassOexByLabmanager(Long[] oeId) {
        oexDao.unpassOexByLabmanager(oeId);
    }

    public void passOexByTeacher(Long[] oeId) {
        oexDao.passOexByTeacher(oeId);
    }

    public void unpassOexByTeacher(Long[] oeId) {
        oexDao.unpassOexByTeacher(oeId);
    }
}
